#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
int n,m,head[MAXN],cnt,fa[MAXN],f[MAXN],sum[MAXN],ans[MAXN];
struct edge
{
	int v,next;
}e[MAXN*2];
struct query
{
	bool opt;
	int x;
}qu[MAXN];
void addedge(int x,int y)
{
	e[++cnt]=(edge){y,head[x]};
	head[x]=cnt;
	return;
}
int getfa(int x)
{
	return fa[x]=fa[x]==x?x:getfa(fa[x]);
}
void dfs(int u,int last)
{
	if(sum[u])fa[u]=u;
	else fa[u]=last;
	f[u]=last;
	for(int i=head[u];i;i=e[i].next)
	{
		int v=e[i].v;
		if(v==last)continue;
		dfs(v,u);
	}
	return;
}
int main()
{
	scanf("%d%d\n",&n,&m);
	for(int i=1;i<n;++i)
	{
		int x,y;
		scanf("%d%d\n",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	sum[1]=1;
	for(int i=1;i<=m;++i)
	{
		char t1;
		scanf("%c %d\n",&t1,&qu[i].x);
		if(t1=='C')++sum[qu[i].x];
		else qu[i].opt=true;
	}
	dfs(1,0);
	cnt=0;
	for(int i=m;i;--i)
	{
		if(qu[i].opt)ans[++cnt]=getfa(fa[qu[i].x]);
		else if(!--sum[qu[i].x])fa[qu[i].x]=f[qu[i].x];
	}
	for(int i=cnt;i;--i)printf("%d\n",ans[i]);
	return 0;
}
